Overview
•	Wpf16_PaperCollection is a small WPF (desktop) app targeting .NET 9 that shows paper-collection statistics for students. It follows a simple MVVM-ish structure (Models, ViewModels, Pages) with Entity Framework Core (Pomelo MySQL provider) for data access.
Project structure (important files / folders)
•	App.xaml / App.xaml.cs — application entry.
•	MainWindow.xaml / MainWindow.xaml.cs — top-level window with a Menu and a Frame used for page navigation.
•	Pages/StatPage.xaml (+ StatPage.xaml.cs) — UI page that displays statistics and student list.
•	ViewModels/StatViewModel.cs — view model backing StatPage, uses CommunityToolkit.Mvvm source generators ([ObservableProperty]).
•	Models/Context.cs and Models/DbPapercollectionContext.cs — EF Core DbContext classes (scaffolded).
•	Models/Student.cs and Models/Submission.cs — EF entities.
How the database connection is set up
•	EF Core with Pomelo.EntityFrameworkCore.MySql is used.
•	Connection string is embedded in Context and DbPapercollectionContext (OnConfiguring): server=jcloud02.jedlik.eu;database=db_papercollection;uid=db_papercollection;pwd=PpColl202602%; ServerVersion parsed as "10.11.14-mariadb".
•	OnModelCreating maps tables/columns to entity properties (table names: students, submissions). Student.Id and Submission.Id are set as keys; Submission has a foreign key student_id pointing to Student.
•	DbContext usage in view model: StatViewModel creates a Context instance directly (Context context = new Context();), calls Load() on DbSets and reads Local collections.
Models and relationships
•	Student: Id (int), Name (string), Class (string), Submissions (ICollection<Submission>).
•	Submission: Id (int), StudentId (int), Date (DateOnly), Quantity (int), Student navigation property.
•	Relationship: one Student has many Submissions; Submission.StudentId is FK.
How pages and XAML are structured and data bound
•	MainWindow contains a Frame named FRM_context. Menu click handler Stat_Click sets FRM_context.Content = new StatPage() to navigate.
•	StatPage.xaml:
•	Declares d:DesignInstance for StatViewModel so the designer can show bindings.
•	Layout: Grid with header (Border/Label) and main StackPanel.
•	Controls bound to StatViewModel properties:
•	Label bound to TotalPaperQuantityText
•	ComboBox ItemsSource="{Binding Classes}" SelectedItem="{Binding SelectedClass}"
•	Label bound to TotalPaperQuantityTextByClass
•	ListBox ItemsSource="{Binding Students}" DisplayMemberPath="Name"
•	StatPage.xaml.cs sets DataContext = new StatViewModel() (View creates and owns its view model).
ViewModel behavior and key logic
•	StatViewModel uses CommunityToolkit.Mvvm.ObservableObject and source-generated properties ([ObservableProperty]).
•	Constructor:
•	Loads submissions and students into EF change tracker (context.Submissions.Load(); context.Students.Load()).
•	Computes total paper quantity in kg: TotalPaperQuantity = context.Submissions.Sum(s => s.Quantity) / 100; (Quantity presumably in 100-gram units).
•	Builds list of classes from students and sets SelectedClass to the first class.
•	OnSelectedClassChanged handler:
•	Computes quantity for that class: context.Submissions.Where(s => s.Student.Class == value).Sum(s => s.Quantity) / 100
•	Updates TotalPaperQuantityTextByClass and Students list filtered by class.
Key takeaways / features
•	Simple MVVM separation: Views (Pages), ViewModels handle logic, Models + EF handle data.
•	Uses EF Core with a scaffolded model mapping to an existing MySQL/MariaDB schema.
•	Uses CommunityToolkit.Mvvm source generators to reduce boilerplate for observable properties.
•	Designer-friendly XAML via d:DataContext to help design-time visuals.
•	Navigation is done by replacing Frame.Content with Page instances (no full navigation service).
Practical notes & suggested improvements
•	Sensitive data: connection string (incl. password) is hard-coded in source. Move to configuration (appsettings.json), user secrets, or environment variables and use options pattern or Name= syntax.
•	DbContext lifetime: StatViewModel creates Context and never disposes it. Use dependency injection (Microsoft.Extensions.DependencyInjection) and scoped lifetimes, or at least dispose contexts or use "using" where appropriate.
•	Async EF calls: use async loading (ToListAsync, SumAsync) to avoid UI blocking.
•	Error handling & null-safety: guard against empty Classes list before indexing Classes[0]; add null checks.
•	Migrations vs scaffolding: current DbContext appears scaffolded from an existing DB. If you plan to evolve schema from code, enable EF Migrations; otherwise keep using scaffolding to refresh models.
•	DateOnly compatibility: ensure provider maps DateOnly correctly; sometimes conversions or EF provider support is needed.
•	Separation of concerns: create a data/repository layer to isolate EF usage from view models for easier testing.
How to run / test locally
•	Ensure .NET 9 runtime installed.
•	Restore NuGet packages (Pomelo, CommunityToolkit.Mvvm, EF Core).
•	Build solution in Visual Studio.
•	The app expects connectivity to the configured MariaDB database. If the DB is not available, either change Context.OnConfiguring to a local DB or mock data in view models for design/testing.
•	Open MainWindow, use the Statisztika menu item to load StatPage and see computed totals.
Where to look in code for specific behavior
•	Database shape & mappings: Models/Context.cs and Models/DbPapercollectionContext.cs (OnModelCreating).
•	Data model: Models/Student.cs and Models/Submission.cs.
•	UI layout and bindings: Pages/StatPage.xaml.
•	View logic & EF usage: ViewModels/StatViewModel.cs.
•	Navigation entry point: MainWindow.xaml.cs (Stat_Click).